## Table 2: Effects of Change in Differential Demand by Month on Wait Times

## install.packages(c("tidyverse", "fixest"))
## library(tidyverse)
## library(fixest)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("demand.RData")

## Column 1
race_wait_demand <- feols(log_mean_wait ~ non_white_demand |
                            city_service + open_month^open_year, 
                          data = demand, 
                          weights = demand$tot_calls)

## Column 2
race_wait_need <- feols(log_mean_wait ~ non_white_need |
                          city_service + open_month^open_year, 
                        data = demand, 
                        weights = demand$tot_calls)

## Column 3
income_wait_demand <- feols(log_mean_wait ~ poor_demand |
                              city_service + open_month^open_year, 
                            data = demand, 
                            weights = demand$tot_calls)

## Column 4
income_wait_need <- feols(log_mean_wait ~ poor_need |
                            city_service + open_month^open_year, 
                          data = demand, 
                          weights = demand$tot_calls)

## Column 5
race_expected_demand <- feols(log_mean_expected ~ non_white_demand |
                                city_service + open_month^open_year, 
                              data = demand, 
                              weights = demand$tot_calls)

## Column 6
race_expected_need <- feols(log_mean_expected ~ non_white_need |
                              city_service + open_month^open_year, 
                            data = demand, 
                            weights = demand$tot_calls)

## Column 7
income_expected_demand <- feols(log_mean_expected ~ poor_demand |
                                  city_service + open_month^open_year, 
                                data = demand, 
                                weights = demand$tot_calls)

## Column 8
income_expected_need <- feols(log_mean_expected ~ poor_need |
                                city_service + open_month^open_year, 
                              data = demand, 
                              weights = demand$tot_calls)

Table2 = etable(race_wait_demand, race_wait_need, 
              income_wait_demand, income_wait_need,
              race_expected_demand, race_expected_need,
              income_expected_demand, income_expected_need,
              signifCode = c("+" = 0.10, "*" = 0.05, "**" = 0.01, "***" = 0.001),
              digits = 3, digits.stats = 3, fitstat = c("n","r2"))
